#!/bin/bash
# 熟悉基础的for ,for c风格,seq , 以及 {}
echo "使用{n..m}输出一组数据"
echo "for i in {1..10};do echo $i;done"
for i in {1..10}
do echo $i
done
echo -e "\e[31m使用步长\e[0m"
echo -e "\e[31mfor i in {1..10..2};do echo $i;done\e[0m"
for i in {1..10..2};do echo $i;done
echo -e "\e[31m{n..m}不能使用变量,例如{1..$i}\e[0m"

echo -e "\e[31m{}还可以组合输出,例如 echo {x,y{a,b,c}{1,2,3}{p,l,k}}\e[0m"
echo {x,y{a,b,c}{1,2,3}{p,l,k}}

echo "使用fro (()) 打印棋盘"

for ((i=1;i<=8;i++))
do
    for ((j=1;j<=8;j++))
    do
        if [[ $[i%2] -eq 0 ]];then
            [ $[j%2] -eq 0 ] && echo -n -e "\e[41m    \e[0m" || echo -n -e "\e[47m    \e[0m"
        else

            [ $[j%2] -eq 0 ] && echo -n -e "\e[47m    \e[0m" || echo -n -e "\e[41m    \e[0m"
        fi
    done
    echo -e -n "\n"
done
